<template>
  <div>
    {{ list.price }}
    <div>
      <van-card num="1" :price="list.price" :title="list.name" :thumb="list.url" />
      <van-submit-bar :price="money" button-text="提交订单" @submit="onSubmit" />
    </div>
  </div>
</template>
  
<script>
export default {
  data() {
    return {
      list: [],
      money: 0
    };
  },
  mounted() {
    this.getcourses();
  },
  methods: {
    getcourses() {
      this.axios
        .get("getcart?userid=" + localStorage.getItem("userid"))
        .then((res) => {
          this.list = res.data.cartlist;
          this.money = res.data.cartlist.price * 100;
        });
    },
    onSubmit() {
      var data = {
        userid: localStorage.getItem("userid"),
        courseid: this.list.id,
      };
      this.axios.post("pay", data).then((res) => {
        console.log(res);
        if (res.data.code == 200) {
          window.location.href = res.data.url;
        }
      });
    },
  }
};
</script>
  
<style></style>